feat:add --dryrun#1422
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: zhou yong kang <mengnankkzhou@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: zhou yong kang <mengnankkzhou@gmail.com>
There was a problem hiding this comment.
Pull Request Overview
This PR implements a --dry-run flag for the libra rm command that shows what files would be removed without actually performing the removal operation. This allows users to preview the effects of their remove command before executing it.
- Adds
dry_runfield toRemoveArgsstruct with appropriate CLI argument configuration - Implements dry-run logic that displays what would be removed while preserving files and index state
- Adds comprehensive test coverage for various dry-run scenarios including basic removal, cached removal, and recursive directory removal
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| libra/src/command/remove.rs | Adds dry_run field to RemoveArgs and implements the core dry-run functionality |
| libra/tests/command/remove_test.rs | Updates existing tests to include dry_run field and adds three new test functions for dry-run scenarios |
| libra/examples/test_dry_run.rs | Provides a standalone example demonstrating the dry-run functionality |
| aria/contents/docs/libra/command/rm/index.mdx | Documents the new --dry-run option with usage examples |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| if index.tracked(&path_wd, 0) { | ||
| println!("rm '{}'", path_wd.bright_yellow()); | ||
| } else { | ||
| // Even untracked files are processed in force mode | ||
| println!("rm '{}'", path_wd.bright_yellow()); | ||
| } |
There was a problem hiding this comment.
The force mode logic has duplicate println! statements that could be simplified. Consider consolidating the output since both tracked and untracked files produce the same message.
| if index.tracked(&path_wd, 0) { | |
| println!("rm '{}'", path_wd.bright_yellow()); | |
| } else { | |
| // Even untracked files are processed in force mode | |
| println!("rm '{}'", path_wd.bright_yellow()); | |
| } | |
| // In force mode, print removal message regardless of tracked status | |
| println!("rm '{}'", path_wd.bright_yellow()); |
| pathspec: vec![file1_path.to_string_lossy().to_string(), file2_path.to_string_lossy().to_string()], | ||
| cached: false, | ||
| recursive: false, | ||
| force: true, // Use force mode to avoid requiring git repository |
There was a problem hiding this comment.
This example won't work correctly because the execute function checks for repository existence at the beginning and returns early if no repository is found, making the force flag ineffective for this purpose.
from #1421